package com.eya.controller;

import com.eya.model.User;
import com.eya.service.UserService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import javax.annotation.Resource;

/**
 * TODO(这个类的作用)
 *
 * @auther: luolin
 * @since: 2018/3/8 16:13
 */
@RestController
@RequestMapping(value = "user")
public class UserController {

	@Autowired
	private DiscoveryClient client;
	@Resource
	private UserService     userService;

	@RequestMapping(value = "getall")
	public List<User> getAllUser() {
		ServiceInstance instance = client.getLocalServiceInstance();
		System.out.print("/getall, host:" + instance.getHost() + ", service_id:" + instance.getServiceId());
		return userService.getAllUser();
	}


}
